<extend name="Base/base" />

<block name="main">
    <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            店铺管理
            <small>preview of simple tables</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">店铺信息</a></li>
            <li class="active">列表</li>
          </ol>
        </section>
        
        <!-- Main content -->
        <section class="content">
         
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 店铺信息管理</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <form  class="form-inline" action="__URL__/index" method="get">
                    <div class="form-group">
                        <label class="sr-only" for="shopname">shopname</label>
                        <input type="input" class="form-control" name="shopname" placeholder="按店名查找">
                    </div>
                     <label class="sr-only"  for="kind">所属类别</label>
                    <select class="form-control" name="kind">
                      <option value="0">--请选择类别--</option>
                      <foreach name="kind" item="k">
                        <option value="{$k.id}">{$k.classname}</option>
                      </foreach>
                    </select>
                    <label class="sr-only"  for="address">地址区域</label>
                    <select class="form-control" name="address">
                      <option value="0">--请选择所在区--</option>
                      <option value="1">小店区</option>
                      <option value="2">迎泽区</option>
                      <option value="3">杏花岭区</option>
                      <option value="4">尖草坪区</option>
                      <option value="5">万柏林区</option>
                      <option value="6">晋源区</option>                      
                    </select>
                    
                    <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
                  </form><br>

                  <table class="table table-bordered">
                    <thead>
                    <tr>
                      <th style="width:60px">ID</th>
                      <th>用户名</th>
                      <th>店名</th>
                      <th>位置</th>
                      <th>类别</th>
                      <th>类型</th>
                     <!--  <th>环境图</th>
                      <th>门脸图</th> -->
                      <th>资质信息</th>
                      <!-- <th>资质信息图</th> -->
                      <th>状态</th>
                      <th>注册时间</th>
                      <th style="width: 160px">操作</th>
                    </tr>
                    </thead>
                  <tbody>
                   <volist name="list" id="vo">
                    <tr>
                      <td> {$vo.id } </td>
                      <td>{$vo.username}</td>
                      <td>{$vo.shopname}</td>                      
                      <td><if condition="($vo.address eq 1) ">小店区<elseif condition="($vo.address eq 2)"/>迎泽区<elseif condition="($vo.address eq 3)"/>杏花岭区<elseif condition="($vo.address eq 4)"/>尖草坪区<elseif condition="($vo.address eq 5)"/>万柏林区<elseif condition="($vo.address eq 6)"/>晋源区</if>{$vo.detail_add} </td>
                      <!-- <td></td> -->
                      <td>{$vo.k}</td>
                      <td><if condition="($vo.shoptype heq '0') ">企业商户<elseif condition="($vo.shoptype eq 1)"/>个体商户</if></td>
                     <!--  <td><img src="__PUBLIC__/Uploads/S_{$vo.env_pic}"></td>
                      <td><img src=" __PUBLIC__/Uploads/S_{$vo.door_pic}"></td>-->
                      <td><if condition="($vo.info heq '0') ">营业执照<elseif condition="($vo.info eq 1)"/>餐饮服务许可证<elseif condition="($vo.info eq 2)"/>其他资质<elseif condition="($vo.info eq 3)"/>无资质</if></td>
                      <!-- <td><img src="__PUBLIC__/Uploads/S_{$vo.info_pic}"></td> -->
                      <td id="state{$vo.id}"><if condition="($vo.state heq '0') ">暂停营业<elseif condition="($vo.state eq 1)"/>审核中<elseif condition="($vo.state eq 2)"/>已审核</if></td>
                      <td>{$vo.addtime|date="Y-m-d",###}</td>
                      <td >
                        <button class="btn btn-xs btn-danger" id="myalert" onclick="doDel(this,{$vo.id})">删除</button> 
                        <button class="btn btn-xs btn-primary" onclick="doEdit({$vo.id})">编辑</button> 
                        <span id="btn{$vo.id}">
                          <button class="btn btn-xs btn-success" onclick="doShen({$vo.id},{$vo.state})">
                            <if condition="($vo.state heq '0') ">重新开业<elseif condition="($vo.state eq 1)"/>通过审核<elseif condition="($vo.state eq 2)"/>暂停营业</if>
                          </button>
                        </span> 
                      </td>
                    </tr>
                    </volist>
                   </tbody>
                  </table>
                </div><!-- /.box-body -->
                <div class="box-footer clearfix">
                    {$page}
                  <!-- </ul> -->
                </div>
              </div><!-- /.box -->

              
              
            </div><!-- /.col -->
            
          </div><!-- /.row -->
         
        </section><!-- /.content -->
        
</block>
<block name="myscript">

  <script type="text/javascript">

       function doDel(obj,id){
            Modal.confirm({msg:'确定要删除当前标签吗？'}).on(function(e){
                if (e) {
                    $.ajax({
                      type:"get",
                      url:"__URL__/del",
                      data:"id="+id,
                      dataType:"json",
                      success:function (data){
                        if(data.b){
                          $(obj).parents("tr").remove();
                        }
                      },
                      error:function () {
                          
                      }
                    });
                }
            })
        }
      function doEdit(id) {
          window.location.href="__CONTROLLER__/edit/id/"+id;
      }
      function doShen(id,state){

           $.ajax({
            type:"get",
            url:"__URL__/doShen",
            data:"id="+id+"&state="+state,
            dataType:"json",
            success:function (data){
              if(data.b){
                  if (data.a==2) {
                    $("#state"+data.id).text("已审核");
                    $("#btn"+data.id).html("<button class='btn btn-xs btn-success' onclick='doShen("+data.id+","+data.a+")'>暂停营业</button>");
                  } else if(data.a===0){
                    $("#state"+data.id).text("停止营业");
                     $("#btn"+data.id).html("<button class='btn btn-xs btn-success' onclick='doShen("+data.id+","+data.a+")'>重新开业</button>");
                  } else if(data.a==1){
                    $("#state"+data.id).text("审核中");
                    $("#btn"+data.id).html("<button class='btn btn-xs btn-success' onclick='doShen("+data.id+","+data.a+")'>通过审核</button>");
                  }    

              }
            },
            error:function () {
                
            }
          });
      }
  </script>
  
</block>